/**
 * @file        main.c
 * @author      JinChengLong (https://gitee.com/Datejin/)
 * @brief       蓝牙遥控小车
 * @version     0.1
 * @date        2023
 * 
 * @copyright   Copyright © 2025 by JinChengLong 
 * 
 * All rights reserved.
 * Unauthorized copying, reproduction, or redistribution of this file via any medium is strictly prohibited.  
 * Proprietary and confidential.
 *   
 */


#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "hcr.h"
#include "OLED_Data.h"
#include "usart.h"
#include <string.h>
#include "MPU6050.h"
#include "servo.h"
#include "motor.h"
#include "DHT.h"
#include "caidan.h"
#include "OLED.h"
#include "motorf.h"
#include "math.h"


//四驱蓝牙车

uint16_t num,n,i;
int16_t ax1,ay1,az1,gx1,gy1,gz1;
int main(void)
{	

	MPU6050_init();
	OLED_Init();
	usart_init(); 
	//HCR04_init();

	OLED_ShowImage(3,1,13,13,shui);
	OLED_ShowImage(3,15,13,13,dian);
	OLED_ShowImage(3,29,13,13,wen);
	OLED_ShowImage (3,43,13,13,chaosheng);
	OLED_ShowImage (17,1,13,13,music);
	OLED_ShowImage (17,15,13,13,zidongtu);
	OLED_ShowImage (17,29,13,13,luxiantu);
	

	OLED_ReverseArea(3,1,13,13);

	servo_angle(90);
	while(1)
	{	
	
		
		OLED_Update ();
		if( usart_getRxflag()==1)
		{
			OLED_ShowImage (45,1,60,60,panglong);
			OLED_Update ();
			 if(strcmp(Serial_RxPacket, "up") == 0)
			{
				  pointup();
				
			}
			 else if(strcmp(Serial_RxPacket, "down") == 0)
			{
				   pointdown();
			}
			 else if(strcmp(Serial_RxPacket, "left") == 0)
			{
				   pointleft();
				
			}
			 else if(strcmp(Serial_RxPacket, "right") == 0)
			{
				   pointright();
				
			}
			
			else if(strcmp(Serial_RxPacket, "xiaoche") == 0)
			{
				xiaoche();
			}
			//
			else if(strcmp(Serial_RxPacket, "TandD") == 0)
			{
				
				TandD();
				
			}
			else if(strcmp(Serial_RxPacket, "laba") == 0)
			{
				
				
				laba();
			}
			
			else if(strcmp(Serial_RxPacket, "I") == 0)
			{
				//
				if(OLED_GetPoint(9,7)==0)
				{			
					TandD();	
				}
				//
				else if(OLED_GetPoint(9,21)==0)
				{	
					 xiaoche();
				}
				
				else if(OLED_GetPoint(9,35)==0)
				{
					 zhuti();
					 
				}
				else if(OLED_GetPoint(9,48)==0)
				{
					
					chaoshengbo();
			
				}
				else if(OLED_GetPoint(22,7)==0)
				{
					laba();
				}
				else if(OLED_GetPoint(22,21)==0)
				{
					xiaoche_xunji();
				}
				else if(OLED_GetPoint(22,35)==0)
				{
					//luxian();
				}
			}
			
		}
		OLED_Update();
	}
}

